﻿using Itfort.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WanPiJie.Products;

namespace WanPiJie.WebSite.Products
{
    public partial class MilkDetail : PageBase
    {
        /// <summary>
        /// 当前页面的产品信息
        /// </summary>
        private Product milkProduct;

        /// <summary>
        /// 当前页面的产品信息
        /// </summary>
        public Product MilkProduct
        {
            get { return milkProduct; }
            set { milkProduct = value; }
        }

        /// <summary>
        /// 商品列表
        /// </summary>
        List<Commodity> milks;

        /// <summary>
        /// 相关产品的商品列表
        /// </summary>
        public List<Commodity> Milks
        {
            get { return milks; }
        }

        protected override void HttpGetProcess()
        {
            base.HttpGetProcess();
            var serialNumber = this.Request.ToInt64("pid");
            if (serialNumber != 0)
            {
                this.milkProduct = WpjSf.ProductService.GetProduct(serialNumber);
                if (this.milkProduct != null)
                {
                    this.milks = WpjSf.CommodityService.GetCommoditiesByProduct(this.milkProduct.SerialNumber, 1, 5);
                }
                else
                {
                    this.Response.Redirect("http://www.wanpijie.com");
                }
            }
            else
            {
                this.Response.Redirect("http://www.wanpijie.com");
            }
        }
    }
}